package com.example.work9.Aspects;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Aspect
@Component
public class LoginAspect {
    @Pointcut("@annotation(com.example.work9.Annotation.LoginLog)")
    public void LoginPointCut() {
    }

    @Around("LoginPointCut()")
    public Object PrintLog(ProceedingJoinPoint pjp)
    {
        try {
           Object result = pjp.proceed();

            System.out.println(pjp.getTarget().getClass().getName());
            System.out.println(pjp.getSignature().getName());
            System.out.println(Arrays.toString(pjp.getArgs()));

           return result;
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }

        return null;
    }
}
